package wifiunion.com.notice.presenter;

import android.content.Context;


import java.util.HashMap;

import wifiunion.com.notice.ConfigureContact;
import wifiunion.com.notice.Constants;
import wifiunion.com.notice.model.AddConfigureModel;

/**
 * Created by Administrator on 2016/12/1.
 */

public class AddConfigurePresenter implements ConfigureContact.Presenter, ConfigureContact.Callback {

    private ConfigureContact.View mView;
    private Context mContext;
    private AddConfigureModel mModel;
    /**
     * 0 场所配置
     * 1 首屏配置
     * 2 获取陌生人清除配置
     * 3 获取人脸识别配置
     * 4 获取通知提醒
     * 5 提交未登记人员管理
     * 6  提交人脸配置
     * 7 提交通知提醒
     * 9 更新抑制时间
     */
    private int mType;


    public AddConfigurePresenter(Context context, ConfigureContact.View view, int type) {
        mView = view;
        mContext = context;
        mModel = new AddConfigureModel();
        mView.setPresenter(this);
        mType = type;
    }

    @Override
    public void onSuccess(Object data) {

        switch (mType) {
            case 0:
                mView.onEditConfigureSuccess();
                break;
            case 1:
                mView.onUpdatePlaceConfigureSuccess();
                break;
            case 2:
                mView.getStrangerConfigueSuccess(data);
                break;
            case 3:
                mView.onUpdateFZPZConfigureSuccess();
                break;
            case 4:
//                mView.get
                break;
            case 5:
                mView.onUpdateStrangerConfigureSuccess();
                break;
            case 6:
                break;
            case 7:
                mView.onUpdateNoticeConfigureSuccess();
                break;
            case 8:
                mView.getDeviceListSuccess(data);
                break;
            case 9:
                mView.updateControltimeSuccess(data);
                break;
        }

    }

    @Override
    public void onServerFailed(Object errorObj) {

        switch (mType) {
            case 0:
                mView.onError((String) errorObj);
                break;
            case 1:
                mView.onUpdatePlaceConfigureFailed(errorObj);
                break;
            case 2:
                mView.getStrangerConfigueFailed(errorObj);
                break;
            case 3:
                mView.onUpdateFZPZConfigureFailed(errorObj);
                break;
            case 4:
                break;
            case 5:
                mView.onUpdateStrangerConfigureFailed(errorObj);
                break;
            case 6:
                break;
            case 7:
                mView.onUpdateNoticeConfigureFailed(errorObj);
                break;
            case 8:
                mView.getDeviceListFailed(errorObj);
                break;
            case 9:
                mView.updateControltimeFailed(errorObj);
                break;
        }

    }

    @Override
    public void onNetFailed() {
        switch (mType) {
            case 0:
                mView.onError("网络异常");
                break;
            case 1:
                mView.onUpdatePlaceConfigureFailed("网络异常");
                break;
            case 2:
                mView.getStrangerConfigueFailed("网络异常");
                break;
            case 3:
                mView.onUpdateStrangerConfigureFailed("网络异常");
                break;
            case 4:
                break;
            case 5:
                mView.onUpdateStrangerConfigureFailed("网络异常");
                break;
            case 6:
                break;
            case 7:
                mView.onUpdateNoticeConfigureFailed("网络异常");
                break;
            case 8:
                mView.getDeviceListFailed("网络异常");
                break;
            case 9:
                mView.updateControltimeFailed("网络异常");
                break;
        }

    }

    @Override
    public void start() {

    }

    @Override
    public void start(HashMap<String, Object> param1s) {
        mModel.loadData(Constants.HTTP_URL_POST_CONFIGURE_UPDATE, param1s, this);
    }


    public void updatePlaceConfigue(HashMap<String, Object> param1s) {
        mModel.updatePlaceLogoConfigue(param1s, this);
    }


//    public void updateStrangerConfigue(HashMap<String, Object> param1s) {
//        mModel.updateStrangerConfigue(param1s, this);
//    }
//
//    public void updateFZPZConfigue(HashMap<String, Object> param1s) {
//        mModel.updateFZPZConfigue(param1s, this);
//    }
//
//    public void getStrangerConfigue(HashMap<String, Object> param1s) {
//        mModel.getStrangerConfigue(param1s, this);
//    }
//
//    public void getDevicelist(HashMap<String, Object> param1s) {
//        mModel.getDevicelist(param1s, this);
//    }

    public void updateMessageConfigue(HashMap<String, Object> params) {
        mModel.updateMessageConfigue(params, this);
    }

    public void updateControlTime(HashMap<String, Object> params) {
        mModel.updateControlTime(params, this);
    }
}
